package com.zhh.springcloud.controller;

import com.zhh.springcloud.feignservice.ConsumerFeignService;
import com.zhh.springcloud.model.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.List;

//消费者层的controller
@RestController
@RequestMapping("/consumer")
public class DeptConsumerController {

    @Autowired
    private ConsumerFeignService deptClientService;  // 使用feign的service接口来实现feign客户端的controller方法

    @PostMapping("/add")
    public Integer add(@RequestBody Department department){
        return deptClientService.add(department);
    }

    @GetMapping("delete")
    public int delete(@RequestParam(value = "id", required = false) int id){
        return deptClientService.delete(id);
    }

    @PostMapping("/modify")
    public int modify(@RequestBody Department department){
        return deptClientService.modify(department);
    }

    @GetMapping("/get")
    public Department get(@RequestParam(value = "id", required = false) int id){
        return deptClientService.getById(id);
    }

    @GetMapping("/getall")
    public List<Department> getall(){
        return deptClientService.getAll();
    }



}
